//
//  CCForumCollectionPushTableViewCell.m
//  CwinCar
//
//  Created by dlios on 15/10/20.
//  Copyright © 2015年 dlios. All rights reserved.
//

#import "CCForumCollectionPushTableViewCell.h"

@implementation CCForumCollectionPushTableViewCell

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.commentLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.84 * mainScreen_Width, mainScree_Height/ 11.116, 0.13 * mainScreen_Width, mainScree_Height / 33.35)];
        [self.contentView addSubview:self.commentLabel];
        self.commentLabel.font = [UIFont systemFontOfSize:13];
        self.commentLabel.textColor = [UIColor colorWithWhite:0.391 alpha:1.];
        self.typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0.50 * mainScreen_Width, mainScree_Height / 11.116, 0.3 * mainScreen_Width, mainScree_Height / 33.35)];
        [self.contentView addSubview:self.typeLabel];
        self.typeLabel.font = [UIFont systemFontOfSize:15];
        self.typeLabel.textColor = [UIColor colorWithWhite:0.391 alpha:1.];
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(mainScreen_Width / 37.5, 0, 0.9 * mainScreen_Width, 0.18 * mainScreen_Width)];
        [self.contentView addSubview:self.titleLabel];
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        [self.titleLabel setNumberOfLines:0];
        
        
        self.timeLabel = [[UILabel alloc]initWithFrame: CGRectMake(mainScreen_Width / 37.5,mainScree_Height / 11.116, 0.4 * mainScreen_Width, mainScree_Height / 33.35)];
        [self.contentView addSubview:self.timeLabel];
        self.timeLabel.font = [UIFont systemFontOfSize:15];
        self.timeLabel.textColor = [UIColor colorWithWhite:0.391 alpha:1.];
        [self.timeLabel setTextAlignment:NSTextAlignmentCenter];
        
        self.iconImage = [[UIImageView alloc]initWithFrame:CGRectMake(0.78 * mainScreen_Width, mainScree_Height / 11.116, 0.06 *mainScreen_Width, mainScree_Height / 33.35)];
        [self.contentView addSubview:self.iconImage];
        self.iconImage.contentMode = UIViewContentModeCenter;
        self.picView = [[UIImageView alloc]initWithFrame:CGRectMake(mainScreen_Width / 2.272, mainScree_Height / 11.116,mainScreen_Width / 18.75, mainScree_Height / 33.35)];
        
        [self.contentView addSubview:self.picView];
        
    }
    return self;
}
- (void)setData:(CCForumPushModel *)collectionModel
{
    if (collectionModel.isTop == true) {
        
        self.timeLabel.text = collectionModel.author;
        [self.iconImage setImage:[UIImage imageNamed:@"dianji_black"]];
    }else
    {
        
        [self.iconImage setImage:[UIImage imageNamed:@"iconfont-luntan-4"]];
        int temp = collectionModel.createDate.intValue;
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:temp];
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
        NSString *tempDate = [formatter stringFromDate:date];
        self.timeLabel.text = tempDate;
        NSString *tempType = [NSString stringWithFormat:@"%@",collectionModel.hasImage];
        if ([tempType isEqual:@"1"]) {
            
            self.isType = YES;
            [self.picView setImage:[UIImage imageNamed:@"biaoqing_tupan"]];
        }else
        {
            self.isType = NO;
        }
        self.typeLabel.text = collectionModel.author;
        
    }
    self.titleLabel.text = collectionModel.postTitle;
    self.commentLabel.text = [NSString stringWithFormat:@"%@",collectionModel.viewCount];
    
}
@end
